/**
 * Created by ljzzkkkss on 2017/9/13.
 */
'use stract';
const dbmanager = require('../evn/dbmanager');


exports.saveCompany = function(data) {
    return new Promise(function (resolve,reject){
        let sql = 'INSERT  INTO company(name,address,num,contact,tel,advance,liscene) VALUE(?,?,?,?,?,?,?)';
        dbmanager.getMasterConn().query(sql,[data.name, data.address,data.num,data.contact,data.tel,data.advance,data.liscene],function(err,result){
            if(err){
                reject(err);
            }else{
                resolve(result);
            }
        });
    });
};


exports.getall = function() {
    return new Promise(function (resolve,reject){
        let sql = 'SELECT  * FROM  `company` ';
        dbmanager.getMasterConn().query(sql,function(err,result){
            if(err){
                reject(err);
            }else{
                resolve(result);
            }
        });
    });
};


exports.getPriceTablle = function() {
    return new Promise(function (resolve,reject){
        let sql = 'SELECT  * FROM  `price` WHERE `status` = 1 ';
        dbmanager.getMasterConn().query(sql,function(err,result){
            if(err){
                reject(err);
            }else{
                resolve(result);
            }
        });
    });
};